<form method="post" action="index.php?app=finance&ctl=axbill&act=add&finder_id=<{$finder_id}>" id="add_form" class="tableform">
    <input type="hidden" value='<{$json}>' id="json" />
        <{input type="hidden" name="pam_account[id]" value=$pam_account.id}>
        <{input type="hidden" name="pam_account[sc_bn]" value=$pam_account.sc_bn}>
    
    <div class="division">
        <table class="gridlist" style="*width:97%;">
            <{ if $pam_account.sc_bn!=''}>
            <tr>
                <th><em class="red">*</em><{t}>单号：<{/t}></th>
                <td><{$pam_account.sc_bn}></td>
            </tr>
            <{/if}>
            <tr>
                <th><em class="red">*</em><{t}>自营店铺：<{/t}></th>
                <td>
                 <select name='pam_account[shop_id]' >
                     <{foreach from=$dly_corp item=dly}>
                     <option value='<{$dly.shop_id}>' <{if $pam_account.shop_id==$dly.shop_id }> selected <{/if}>>【<{$dly.shop_bn}>】<{$dly.name}></option>
                     <{/foreach}>
                  </select>
                </td>
            </tr>
            <tr>
                <td><em class="red">*</em><{t}>费用类型：<{/t}></td>
                <td>
                    <select vtype="required" id="fee_type" onchange='change_fee_type(this.value)'>
                        <{foreach from=$fee_type_data key=key item=val}>
                        <option value="<{$key}>"><{$val.name}></option>
                        <{/foreach}>
                    </select>
                </td>
            </tr>
            <tr>
                <td><em class="red">*</em><{t}>费用名称：<{/t}></td>
                <td>
                    <div id='replace_type'>
                        <select  vtype="required" name="fee_item">
                            <{foreach from=$fee_type_data key=key item=val name=foo}>
                            <{if $smarty.foreach.foo.first}>
                            <{foreach from=$val['fee_item'] item=item key=id}>
                            <option value="<{$item}>"><{$item}></option>
                            <{/foreach}>
                            <{/if}>
                            <{/foreach}>
                        </select>
                    </div>
                </td>
            </tr>
            <tr>
                <th><em class="red">*</em><{t}>开始日期：<{/t}></th>
                <td><{input type="date" name="pam_account[begin_date]"  value=$pam_account.begin_date  size="20" vtype="required"}></td>
            </tr>
            <tr>
                <th><em class="red">*</em><{t}>结束日期：<{/t}></th>
                <td><{input type="date" name="pam_account[end_date]"  value=$pam_account.end_date  size="20" vtype="required"}></td>
            </tr>
            <tr>
                <th><em class="red">*</em><{t}>入账时间：<{/t}></th>
                <td><{input type="date" name="pam_account[booked_time]" value=$pam_account.booked_time  size="20" vtype="required"}></td>
            </tr>
            <tr>
                <th><{t}>操作员：<{/t}></th>
                <td><{input type="text" name="pam_account[operator]"  value=$pam_account.operator size="20" }></td>
            </tr>
            <tr>
                <th><{t}>备注：<{/t}></th>
                <td><textarea id="remark" maxth="255" rows="3" cols="80%" name="pam_account[remark]" type="textarea"><{$pam_account.remark}></textarea></td>
            </tr>
        </table>

        <div align="center">
            <button value="提交" id="btn-do-confirm" class="btn btn-primary" onclick="do_submit()" >
                <span>
                    <span>确定</span>
                </span>
            </button>
        </div>
    </div>
</form>
<script>
var form = $('add_form');
form.store('target',{
    onRequest:function (){
        $('add_form').set('disabled', 'true');
        $('add_form').getElements('span')[1].set('text','处理中');
    },
    onComplete:function(rs){
        var result = JSON.decode(rs);
        if (typeof(result.error) != 'undefined'){
            $('add_form').set('disabled', '');
            $('add_form').getElements('span')[1].set('text','确定');
        }else {
            $('add_form').getParent('.dialog').retrieve('instance').close();
            finderGroup['<{$env.get.finder_id}>'].refresh();
        }
    }
});
function do_submit(){
    $('add_form').fireEvent('submit',{stop:function(){}});
}
function change_fee_type(type_id){
    var json = $('json').value;
    a = JSON.decode(json);
    rs = a[type_id]['fee_item'];
    var option='',v='';
    for(v in rs) {
        option += '<option value="'+rs[v]+'">'+rs[v]+'</option>';
    }
    var left = '<select  vtype="required" name="fee_item">';
    var middle = option;
    var right = '</select>'
    var html = left+middle+right;
    $('replace_type').set('html',html);
}
</script>